/**
 * loading 高阶
 */
import React from 'react';
import './index.less';
import { Spin } from 'antd';
import 'antd/es/spin/style/index';

var defaultData = {
  loading: true,
};

export default (data = defaultData) => Comp => {
  var config = { ...defaultData, ...data };
  return class extends React.Component {
    state = {
      loading: config.loading,
    };
    setLoading = loading => {
      this.setState({ loading });
    };
    render() {
      return (
        <div className={'sty-ai-common-BoxLoadingHoc'}>
          <Spin
            spinning={this.state.loading}
            size="large"
            delay={100}
          >
            <Comp {...this.props} loading={this.state.loading} setLoading={this.setLoading}></Comp>
          </Spin>
        </div>
      );
    }
  };
};
